home *** CD-ROM | disk | FTP | other *** search
/ IRIX Base Documentation 2002 November / SGI IRIX Base Documentation 2002 November.iso / usr / share / catman / p_man / cat3 / c++ / fstream.z / fstream
Encoding:
Text File  |  2002-10-03  |  12.4 KB  |  197 lines

  1. FSTREAM(3C)                                            Last changed: 1-7-99
  2.  
  3.  
  4. NNAAMMEE
  5.      ffssttrreeaamm - iostream and streambuf specialized to files
  6.  
  7. SSYYNNOOPPSSIISS
  8.      ##iinncclluuddee <<ffssttrreeaamm..hh>>
  9.  
  10.      ttyyppeeddeeff lloonngg ssttrreeaammooffff,, ssttrreeaammppooss;;
  11.      ccllaassss iiooss {{
  12.      ppuubblliicc::
  13.           eennuumm sseeeekk__ddiirr {{ bbeegg,, ccuurr,, eenndd }} ;;
  14.           eennuumm ooppeenn__mmooddee {{ iinn,, oouutt,, aattee,, aapppp,, ttrruunncc,, nnooccrreeaattee,, nnoorreeppllaaccee }}
  15.      ;;
  16.           eennuumm iioo__ssttaattee {{ ggooooddbbiitt==00,, eeooffbbiitt,, ffaaiillbbiitt,, bbaaddbbiitt }} ;;
  17.           //// aanndd lloottss ooff ootthheerr ssttuuffff,, sseeee iiooss((33CC)) ......
  18.      }} ;;
  19.  
  20.      ccllaassss iiffssttrreeaamm :: iissttrreeaamm {{
  21.                iiffssttrreeaamm(()) ;;
  22.                ~~iiffssttrreeaamm(()) ;;
  23.                iiffssttrreeaamm((ccoonnsstt cchhaarr** nnaammee,, iinntt ==iiooss::::iinn,,
  24.                               iinntt pprroott ==ffiilleebbuuff::::ooppeennpprroott)) ;;
  25.                iiffssttrreeaamm((iinntt ffdd)) ;;
  26.                iiffssttrreeaamm((iinntt ffdd,, cchhaarr** pp,, iinntt ll)) ;;
  27.  
  28.           vvooiidd aattttaacchh((iinntt ffdd)) ;;
  29.           vvooiidd cclloossee(()) ;;
  30.           vvooiidd ooppeenn((cchhaarr** nnaammee,, iinntt ==iiooss::::iinn,,
  31.                     iinntt pprroott==ffiilleebbuuff::::ooppeennpprroott)) ;;
  32.           ffiilleebbuuff**  rrddbbuuff(()) ;;
  33.           vvooiidd sseettbbuuff((cchhaarr** pp,, iinntt ll)) ;;
  34.      }};;
  35.  
  36.      ccllaassss ooffssttrreeaamm :: oossttrreeaamm {{
  37.                ooffssttrreeaamm(()) ;;
  38.                ~~ooffssttrreeaamm(()) ;;
  39.                ooffssttrreeaamm((ccoonnsstt cchhaarr** nnaammee,, iinntt ==iiooss::::oouutt,,
  40.                               iinntt pprroott ==ffiilleebbuuff::::ooppeennpprroott)) ;;
  41.                ooffssttrreeaamm((iinntt ffdd)) ;;
  42.                ooffssttrreeaamm((iinntt ffdd,, cchhaarr** pp,, iinntt ll)) ;;
  43.  
  44.           vvooiidd aattttaacchh((iinntt ffdd)) ;;
  45.           vvooiidd cclloossee(()) ;;
  46.           vvooiidd ooppeenn((cchhaarr** nnaammee,, iinntt ==iiooss::::oouutt,, iinntt pprroott==ffiilleebbuuff::::ooppeennpprroott))
  47.      ;;
  48.           ffiilleebbuuff**  rrddbbuuff(()) ;;
  49.           vvooiidd sseettbbuuff((cchhaarr** pp,, iinntt ll)) ;;
  50.      }};;
  51.  
  52.      ccllaassss ffssttrreeaamm :: iioossttrreeaamm {{
  53.                ffssttrreeaamm(()) ;;
  54.                ~~ffssttrreeaamm(()) ;;
  55.                ffssttrreeaamm((ccoonnsstt cchhaarr** nnaammee,, iinntt mmooddee,,
  56.                               iinntt pprroott ==ffiilleebbuuff::::ooppeennpprroott)) ;;
  57.                ffssttrreeaamm((iinntt ffdd)) ;;
  58.                ffssttrreeaamm((iinntt ffdd,, cchhaarr** pp,, iinntt ll)) ;;
  59.  
  60.           vvooiidd aattttaacchh((iinntt ffdd)) ;;
  61.           vvooiidd cclloossee(()) ;;
  62.           vvooiidd ooppeenn((cchhaarr** nnaammee,, iinntt mmooddee,, iinntt pprroott==ffiilleebbuuff::::ooppeennpprroott)) ;;
  63.           ffiilleebbuuff**  rrddbbuuff(()) ;;
  64.           vvooiidd sseettbbuuff((cchhaarr** pp,, iinntt ll)) ;;
  65.      }};;
  66.  
  67. IIMMPPLLEEMMEENNTTAATTIIOONN
  68.      IRIX systems
  69.  
  70. DDEESSCCRRIIPPTTIIOONN
  71.      iiffssttrreeaamm, ooffssttrreeaamm, and ffssttrreeaamm specialize iissttrreeaamm, oossttrreeaamm, and
  72.      iioossttrreeaamm, respectively, to files.  That is, the associated ssttrreeaammbbuuff
  73.      will be a ffiilleebbuuff.
  74.  
  75.      In the following descriptions, assume that:
  76.  
  77.      * _f is any of iiffssttrreeaamm, ooffssttrreeaamm, or ffssttrreeaamm.
  78.  
  79.      * _p_f_b is a ffiilleebbuuff**.
  80.  
  81.      * _p_s_b is a ssttrreeaammbbuuff**.
  82.  
  83.      * _n_a_m_e and _p_t_r are cchhaarr**s.
  84.  
  85.      * _i, _f_d, _l_e_n, and _p_r_o_t are iinntts.
  86.  
  87.      * _m_o_d_e is an iinntt representing an ooppeenn__mmooddee.
  88.  
  89.    CCoonnssttrruuccttoorrss
  90.      The following constructors are for _xssttrreeaamm, _w_h_e_r_e _x _i_s _e_i_t_h_e_r iiff, ooff,
  91.      _o_r ff:
  92.  
  93.           _xssttrreeaamm(())
  94.                Constructs an unopened _xssttrreeaamm.
  95.  
  96.           _xssttrreeaamm((_n_a_m_e,, _m_o_d_e,, _p_r_o_t))
  97.                Constructs an _xssttrreeaamm _a_n_d _o_p_e_n_s _f_i_l_e _n_a_m_e _u_s_i_n_g _m_o_d_e _a_s _t_h_e
  98.                _o_p_e_n _m_o_d_e _a_n_d _p_r_o_t _a_s _t_h_e _p_r_o_t_e_c_t_i_o_n _m_o_d_e.  _B_y _d_e_f_a_u_l_t, _p_r_o_t
  99.                _i_s ffiilleebbuuff::::ooppeennpprroott, _w_h_i_c_h _i_s _0_6_4_4.  _T_h_e _e_r_r_o_r _s_t_a_t_e
  100.                (iioo__ssttaattee) _o_f _t_h_e _c_o_n_s_t_r_u_c_t_e_d _xssttrreeaamm _w_i_l_l _i_n_d_i_c_a_t_e _f_a_i_l_u_r_e
  101.                _i_n _c_a_s_e _t_h_e ooppeenn _f_a_i_l_s.
  102.  
  103.           _xssttrreeaamm((_d))
  104.                Constructs an _xssttrreeaamm _c_o_n_n_e_c_t_e_d _t_o _f_i_l_e _d_e_s_c_r_i_p_t_o_r _d, _w_h_i_c_h
  105.                _m_u_s_t _b_e _a_l_r_e_a_d_y _o_p_e_n.
  106.  
  107.           _xssttrreeaamm((_d,,_p_t_r,,_l_e_n))
  108.                Constructs an _xssttrreeaamm _c_o_n_n_e_c_t_e_d _t_o _f_i_l_e _d_e_s_c_r_i_p_t_o_r _d, _a_n_d,
  109.                _i_n _a_d_d_i_t_i_o_n, _i_n_i_t_i_a_l_i_z_e_s _t_h_e _a_s_s_o_c_i_a_t_e_d ffiilleebbuuff _t_o _u_s_e _t_h_e
  110.                _l_e_n _b_y_t_e_s _a_t _p_t_r _a_s _t_h_e _r_e_s_e_r_v_e _a_r_e_a.  _I_f _p_t_r _i_s _n_u_l_l _o_r _l_e_n
  111.                _i_s _0, _t_h_e ffiilleebbuuff _w_i_l_l _b_e _u_n_b_u_f_f_e_r_e_d.
  112.  
  113.    MMeemmbbeerr ffuunnccttiioonnss
  114.           _f..aattttaacchh((_d))
  115.                Connects _f to the file descriptor _d.  A failure occurs when
  116.                _f is already connected to a file.  A failure sets
  117.                iiooss::::ffaaiillbbiitt in _f's error state.
  118.  
  119.           _f..cclloossee(())
  120.                Closes any associated ffiilleebbuuff and thereby breaks the
  121.                connection of the _f to a file.  _f's error state is cleared
  122.                except on failure.  A failure occurs when the call to
  123.                _f..rrddbbuuff(())-->>cclloossee(()) _f_a_i_l_s.
  124.  
  125.           _f..ooppeenn((_n_a_m_e,,_m_o_d_e,,_p_r_o_t))
  126.                Opens file _n_a_m_e and connects _f to it.  If the file does not
  127.                already exist, an attempt is made to create it with
  128.                protection mode _p_r_o_t unless iiooss::::nnooccrreeaattee is set.  By
  129.                default, _p_r_o_t is ffiilleebbuuff::::ooppeennpprroott, which is 0644.  Failure
  130.                occurs if _f is already open, or the call to _f..rrddbbuuff(())--
  131.                >>ooppeenn(()) _f_a_i_l_s.  iiooss::::ffaaiillbbiitt _i_s _s_e_t _i_n _f'_s _e_r_r_o_r _s_t_a_t_u_s _o_n
  132.                _f_a_i_l_u_r_e.  _T_h_e _m_e_m_b_e_r_s _o_f ooppeenn__mmooddee _a_r_e _b_i_t_s _t_h_a_t _m_a_y _b_e
  133.                _o_r'_e_d _t_o_g_e_t_h_e_r.  (_B_e_c_a_u_s_e _t_h_e _o_r'_i_n_g _r_e_t_u_r_n_s _a_n iinntt, ooppeenn(())
  134.                _t_a_k_e_s _a_n iinntt _r_a_t_h_e_r _t_h_a_n _a_n ooppeenn__mmooddee _a_r_g_u_m_e_n_t.)  _T_h_e
  135.                _m_e_a_n_i_n_g_s _o_f _t_h_e_s_e _b_i_t_s _i_n _m_o_d_e _a_r_e:
  136.  
  137.                iiooss::::aapppp
  138.                     A seek to the end of file is performed.  Subsequent
  139.                     data written to the file is always added (appended) at
  140.                     the end of file.  On some systems this is implemented
  141.                     in the operating system.  In others it is implemented
  142.                     by seeking to the end of the file before each write.
  143.                     iiooss::::aapppp implies iiooss::::oouutt.
  144.  
  145.                iiooss::::aattee
  146.                     A seek to the end of the file is performed during the
  147.                     ooppeenn(()).  iiooss::::aattee does not imply iiooss::::oouutt.
  148.  
  149.                iiooss::::iinn
  150.                     The file is opened for input.  iiooss::::iinn is implied by
  151.                     construction and opens of iiffssttrreeaamms.  For ffssttrreeaamms it
  152.                     indicates that input operations should be allowed if
  153.                     possible.  Is is legal to include iiooss::::iinn in the modes
  154.                     of an oossttrreeaamm in which case it implies that the
  155.                     original file (if it exists) should not be truncated.
  156.                     If the file being opened for input does not exist, the
  157.                     open will fail.
  158.  
  159.                iiooss::::oouutt
  160.                     The file is opened for output.  iiooss::::oouutt is implied by
  161.                     construction and opens of ooffssttrreeaamms.  For ffssttrreeaamm it
  162.                     says that output operations are to be allowed.
  163.                     iiooss::::oouutt may be specified even if _p_r_o_t does not permit
  164.                     output.
  165.  
  166.                iiooss::::ttrruunncc
  167.                     If the file already exists, its contents will be
  168.                     truncated (discarded).  This mode is implied when
  169.                     iiooss::::oouutt is specified (including implicit specification
  170.                     for ooffssttrreeaamm) and neither iiooss::::aattee nor iiooss::::aapppp is
  171.                     specified.
  172.  
  173.                iiooss::::nnooccrreeaattee
  174.                     If the file does not already exist, the ooppeenn(()) will
  175.                     fail.
  176.  
  177.                iiooss::::nnoorreeppllaaccee
  178.                     If the file already exists, the ooppeenn(()) will fail.  Only
  179.                     valid with iiooss::::oouutt.
  180.  
  181.           _p_f_b==_f..rrddbbuuff(())
  182.                Returns a pointer to the ffiilleebbuuff associated with _f.
  183.                ffssttrreeaamm::::rrddbbuuff(()) has the same meaning as iioossttrreeaamm::::rrddbbuuff(())
  184.                but is typed differently.
  185.  
  186.           _f..sseettbbuuff((_p,,_l_e_n))
  187.                Has the usual effect of a sseettbbuuff(()) (see ffiilleebbuuff(3C)),
  188.                offering space for a reserve area or requesting unbuffered
  189.                I/O.  Normally the returned _p_s_b is _f..rrddbbuuff(()), _b_u_t _i_t _i_s _0 _o_n
  190.                _f_a_i_l_u_r_e.  _A _f_a_i_l_u_r_e _o_c_c_u_r_s _i_f _f _i_s _o_p_e_n _o_r _t_h_e _c_a_l_l _t_o
  191.                _f..rrddbbuuff(())-->>sseettbbuuff _f_a_i_l_s.
  192.  
  193. SSEEEE AALLSSOO
  194.      ffiilleebbuuff(3C), iissttrreeaamm(3C), iiooss(3C), oossttrreeaamm(3C), ssbbuuff..ppuubb(3C)
  195.  
  196.      This man page is available only online.
  197.